import com.example.pojo.Account;
import com.example.service.DemoService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:application*.xml"})
public class MybatisSpring {

    @Autowired
    private DemoService demoService;

    @Test
    public void testMybatisSpring() {
        List<Account> accounts = demoService.listAccount();
        for (Account account : accounts) {
            System.out.println(account);
        }

        // 测试事务
        demoService.transferMoney();
        System.out.println("ok.");
    }
}

